package xyz.flowlight.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import xyz.flowlight.domain.response.ResponseResult;
import xyz.flowlight.service.LikeService;

@Tag(name = "点赞相关接口")
@RestController
@RequestMapping("/like")
public class LikeController {
    @Resource
    private LikeService likeService;

    @PostMapping("/toggle/{productId}")
    public ResponseResult<Boolean> toggleLike(@PathVariable Integer productId,
                                              @RequestHeader("userId") Integer userId) {
        return likeService.toggleLike(userId, productId);
    }

    @GetMapping("/status/{productId}")
    public ResponseResult<Boolean> getLikeStatus(@PathVariable Integer productId,
                                               @RequestHeader("userId") Integer userId) {
        return likeService.isLiked(userId, productId);
    }
}
